<?php


    // Author: Tomasz Durka
    // Date: 4th April 2007
    // Prints out a HTML submit tag
    
    
  function vselect ($name, $options, array $params = array()) {
    $id = $name;
    
    if (is_a($options, 'ActiveRecordCollection') || is_a($options, 'Collection')) {
      $options = $options->to_array();
    }
    //pc($options);
    
    $keys = array_keys($options);
    $selected = $params['selected'] ? $params['selected'] : $keys[0];
    
    $r = "<span id=\"{$id}_area\" style=\"display: none; position: absolute; background-color: #fff; border: 1px solid #ccc; padding: 0px;\" onMouseOver=\"$('{$id}_area').show();\" onMouseOut=\"$('{$id}_area').hide();\">";
    foreach ($options as $key => $value) {
      $r .= "<a href=\"\" onClick=\"$('{$id}_area').hide(); $('{$id}_link').update(this.innerHTML); return false;\" style=\"display: block; padding: 2px 6px;\">{$value}</a>";
    }
    $r .= "</span>";
    $r .= "<a href=\"\" id=\"{$id}_link\" onClick=\"$('{$id}_area').show(); return false;\" style=\"margin-left: 1px;\" >{$options[$selected]}</a>";
    //<!--style="border: 1px solid #ccc; padding: 6px;"-->
    return $r;
  }

?>